/*
  将下面异步代码使用 Promise 的方法改进
  尽量用看上去像同步代码的方式
  setTimeout(function () {
    var a = 'hello'
    setTimeout(function () {
      var b = 'lagou'
      setTimeout(function () {
        var c = 'I ♥ U'
        console.log(a + b +c)
      }, 10)
    }, 10)
  }, 10)
*/



let p1 = new Promise((resolve)=>{
  setTimeout(()=>{
    var a= 'hello'
    resolve(a)
  },10)
})
let p2 = new Promise((resolve) => {
  setTimeout(()=>{
    var b= 'lagou'
    resolve(b)
  },10)
})

let p3 = new Promise((resolve) =>{
  setTimeout(() =>{
    var c = 'i love you'
    resolve(c)
  },10)
})

let res = ''
p1.then( val1 => {
  res += val1
  return p2
}).then(val2 => {
  res += val2
  return p3
}).then(val3 => {
  console.log( 'promise=', res += val3)
})
